package logic

import (
	"context"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"user_srv/model"
	"user_srv/user_proto"
)

type Server struct {
	user_proto.UnimplementedUserServer
}

func (s *Server) UserRegister(ctx context.Context, in *user_proto.UserRegisterRequest) (*user_proto.UserRegisterResponse, error) {
	user := model.User{
		Mobile:   in.Mobile,
		Password: in.Password,
	}
	err := user.Register()
	if err != nil {
		return nil, status.Errorf(codes.Internal, "用户注册失败")
	}
	return &user_proto.UserRegisterResponse{}, nil
}
